import jwt
import datetime

# 载荷信息
payload = {'exp':int((datetime.datetime.now()+datetime.timedelta(seconds=30)).timestamp()),
	'data':{'uid':4,'username':'lsc'}}

# 编码
encode_jwt = jwt.encode(payload,'123',algorithm='HS256')

print(encode_jwt)

# 强转
encode_str = str(encode_jwt,'utf-8')

print(encode_str)

# 解密
decode_jwt = jwt.decode(encode_str,'123',algorithm=['HS256'])

print(decode_jwt)